package com.kaikai.edu.controller;


import com.kaikai.commonutils.R;
import com.kaikai.edu.entity.ao.EduEmailQueryAO;
import com.kaikai.edu.entity.ao.EduEmailSendAO;
import com.kaikai.edu.service.EduEmailService;
import com.kaikai.edu.service.impl.EmailServiceImpl;
import io.swagger.annotations.ApiImplicitParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author yujiankai
 * @since 2022-01-05
 */
@RestController
@RequestMapping("/eduservice/email")
public class EmailController {

    @Autowired
    private EduEmailService emailService;
    /**
     * @param sendAO
     * @return com.kaikai.commonutils.R
     * @Author yujiankai
     * @Description 邮件发送
     * @date 2022/1/6 16:47
     */
    @PostMapping("/sendEmail")
    public R sendEmail(@RequestBody @Valid EduEmailSendAO sendAO){
        return emailService.sendEmail(sendAO);
    }

    /**
     * @param queryAO
     * @return com.kaikai.commonutils.R
     * @Author yujiankai
     * @Description 查询邮件发送记录
     * @date 2022/1/9 14:58
     */
    @PostMapping("/queryEmailSendRecList")
    public R queryEmailSendRecList(@RequestBody @Valid EduEmailQueryAO queryAO){
        return emailService.queryEmailSendRecList(queryAO);
    }

    /**
     * @param emailId
     * @return com.kaikai.commonutils.R
     * @Author yujiankai
     * @Description 消息重发
     * @date 2022/1/21 14:24
     */
    @ApiImplicitParam(name = "emailId", value = "邮件发送id", required = true)
    @GetMapping("/resendEmail/{emailId}")
    public R resendEmail(@PathVariable String emailId){
        return emailService.resendEmail(emailId);
    }


    @GetMapping("getUserList")
    public R getUserList(){
        return emailService.getUserList();
    }
}

